
%!TEX program = xelatex
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[10pt]{article} 

\input{wang_preamble.tex}

\begin{document}

\begin{center}
\includegraphics [width=0.85\textwidth, height=4.1cm]{lixin-pan-new.eps}
\end{center}

\vspace{-0.6cm}

\begin{center}
%{\LARGE\bf 上海立信会计金融学院期终考试卷 --- 试题纸} \hspace{0.3cm} {\Large \underline{ A }卷 }
{\Large\bf \H 上海立信会计金融学院期终考试卷 } \hspace{0.3cm} {\Large \underline{ A }卷 }

\vspace{0.3cm}

{\large \bf \H 2022 $\sim$ 2023 学年 第 二 学期 }

\vspace{0.3cm}

{\large \bf \H \underline{ \emph{2021级数学与应用数学专业} } 《\underline{ \emph{统计软件} }》 课程代码：\underline{ 160960214 }  }

\vspace{0.3cm}

{\H（本场考试属\underline{  开  }卷考试，考试时间共\underline{  90  }分钟，不准使用计算器）共\underline{  4  }页 }
%{\large （本场考试属闭卷考试，考试时间 90 分钟，禁止使用计算器） }

\vspace{0.3cm}

%{\large 本考试卷共 4 页，请在本考试卷上答题。}

%\vspace{-0.3cm}
%\rule[-.3\baselineskip]{\textwidth}{0.2pt}

\vspace{0.4cm}

班级 \underline{\hspace{3.5cm}} 学号 \underline{\hspace{3.5cm}} 姓名 \underline{\hspace{3.5cm}} 

\end{center}

\vspace{-0.2cm}

{\H
\begin{table}[h]
%\caption{Nonlinear Model Results} % title of Table
\centering % used for centering table
\renewcommand{\arraystretch}{1.4}
\begin{tabular}{
|>{\centering\arraybackslash}p{0.9cm}
|>{\centering\arraybackslash}p{0.9cm}|>{\centering\arraybackslash}p{0.9cm}|>{\centering\arraybackslash}p{0.9cm}
|>{\centering\arraybackslash}p{0.9cm}|>{\centering\arraybackslash}p{0.9cm}|>{\centering\arraybackslash}p{0.9cm}
|>{\centering\arraybackslash}p{0.9cm}|>{\centering\arraybackslash}p{0.9cm}|>{\centering\arraybackslash}p{0.9cm}
|>{\centering\arraybackslash}p{1.1cm}|>{\centering\arraybackslash}p{1.1cm}|}
\hline
题号 &一&二&三&四&五&六&七&八&总分&合成人签名&审核人签名 \\
%\hline
%应得分&15&15&15&15&15&15&10&100 \\
\hline
得分 $\,\,\,\,\,\,\,\,$ &&&&&&&&&&& \\
\hline
\end{tabular}
\end{table}
}

%%%%%%%%%%%%%%%%%%%% 试题从这里开始 %%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%% 试题从这里开始 %%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%% 试题从这里开始 %%%%%%%%%%%%%%%%%%%%

本次考试主要是对概率统计问题和R语言代码的阅读理解。请用完整的句子：
（1）解释题目里提出的问题并回答，（2）解释带\#\#的代码的含义（写在代码的旁边），（3）写下对本题的进一步思考。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{enumerate}

%5.2\# 1, 2, 3, 4, 5.  
%5.3\# 1, 20, 22, 35, 36. 
%5.4\# 1, 4, 13, 14, 20. 
%6.2\# 1, 2.  
%6.3\# 4, 6. 
%6.6\# 5, 12. 
%7.2\# 1, 3, 4, 6, 10, 11, 12, 14, 16, 17, 18, 20, 21, 24, 26. 
%7.6\# 6, 7, 8. 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %2 mss - page 85 - 例 2.4.3 
甲、乙两棋手进行 20 局比赛，以赢的局数多者为胜。
设在每局中甲赢的概率为 0.52, 乙赢的概率为 0.48. 
设各局比赛是独立进行的。
使用R语言辅助计算，求甲胜、乙胜、不分胜负的各个概率。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{lstlisting}[language=R]
> k=11:20
> x=choose(20,k)*(0.52)^k*(0.48)^(20-k)  ##
> sum(x)  ##
[1] 0.4834428
> k=0:9
> y=choose(20,k)*(0.52)^k*(0.48)^(20-k)
> sum(y)
[1] 0.3431591
> k=10
> z=choose(20,k)*(0.52)^k*(0.48)^(20-k)
> z
[1] 0.1733981

> sum(dbinom(11:20,size=20,prob=0.52))  ## 
[1] 0.4834428
> sum(dbinom(0:9,size=20,prob=0.52))
[1] 0.3431591
> dbinom(10,size=20,prob=0.52)
[1] 0.1733981
\end{lstlisting}

\vspace{0.2cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %1 mss - page 16 - 例子1.2.3. 
一批产品共有 $N=200$ 件，其中 $M=10$ 件是不合格品， $N-M=190$ 件是合格品。
从中随机取出 $n=20$ 件。
使用R语言辅助计算，求事件 $A_2 = $ “取出的 $n=20$ 件产品中有 $m=2$ 件不合格品”的概率。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{lstlisting}[language=R]
> choose(190,18)*choose(10,2)/choose(200,20)  ## 
[1] 0.1975432
\end{lstlisting}


\vspace{3cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %3
设二维随机变量 $(X,Y)$ 服从二元正态分布，即 $(X,Y)\sim N(\mu_1,\mu_2,\sigma_1^2,\sigma_2^2,\rho)$. 
\begin{enumerate}
\item  写出 $(X,Y)$ 的联合概率密度函数。
\item  使用R语言模拟生成一些服从二元正态分布的随机向量 $(x_k,y_k), 1\le k\le n$. 
\end{enumerate}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{lstlisting}[language=R]
rho = 0.60
n = 500
x = rnorm(n)  ## 
y = rnorm(n,rho*x,sqrt(1-rho^2))  ## 
plot(x,y,pch=21, col='blue', xlim=c(-5,5),ylim=c(-5,5))  ## 
\end{lstlisting}

\vspace{3cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %4 mss - page 213 - 例子4.4.3. 正态随机数的产生
应用中心极限定理，可以从均匀分布的随机数出发，产生正态分布的随机数。具体方法如下。
\begin{enumerate}
\item[(1)]  设有区间 $[0,1]$ 上的均匀分布的随机数 $x_1,x_2,\cdots,x_{12}$. 
\item[(2)]  计算 $y=x_1+\cdots+x_{12}-6$. 
\item[(3)]  重复(1)-(2), 得到一系列的 $y$. 
\end{enumerate}
使用R语言验证这样得到的随机数 $y$ 近似服从正态分布。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{lstlisting}[language=R]
> n=1000
> x=matrix(runif(12*n),nrow=n)  ## 
> y=rowSums(x)-6  ## 
> hist(y)
> qqnorm(y)  ##
> shapiro.test(y)  ## 

	Shapiro-Wilk normality test

data:  y
W = 0.99866, p-value = 0.6611
\end{lstlisting}

\vspace{0.2cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %5 mss - page 242 - 例子5.3.8.
设总体为均匀分布 $U(0,1)$. 设 $x_1,x_2,\cdots,x_n$ 为简单随机样本。设 $x_{(1)},x_{(2)},\cdots,x_{(n)}$ 为次序统计量。
使用R语言验证 $x_{(k)}$ 的数学期望为 $\frac{k}{n+1}$. 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{lstlisting}[language=R]
> N=1000
> n=4
> y=0
> for (m in 1:N){     ##
+   x=runif(n)        ##
+   y[m]=sort(x)[2]   ##
+ }
> mean(y)  ##
[1] 0.3949853
> 2/(n+1)
[1] 0.4
\end{lstlisting}

\vspace{4cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %6 mss - page 305 - 例子6.6.6.
设某厂生产的零件的质量服从正态分布 $N(\mu,\sigma^2)$, 单位：克。设从一批产品中抽取10个，测得质量如下。
\begin{center}
\begin{tabular}{cccccccccc} \hline 
18.4 & 21.4 & 17.2 & 18.0 & 21.2 & 22.0 & 20.2 & 21.6 & 19.4 & 20.3 \\ \hline 
\end{tabular}
\end{center}
求总体标准差 $\sigma$ 的0.95 和 0.99 置信区间。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{lstlisting}[language=R]
> x=c(18.4, 21.4, 17.2, 18.0, 21.2, 22.0, 20.2, 21.6, 19.4, 20.3)
> s=sd(x)  ##
> n=length(x)
> s1sq=(n-1)*s^2/qchisq(0.975,n-1)  ##
> s2sq=(n-1)*s^2/qchisq(0.025,n-1)
> s1=sqrt(s1sq)  ##
> s2=sqrt(s2sq)
> s1
[1] 1.142741
> s2
[1] 3.032992

> s1sq=(n-1)*s^2/qchisq(0.995,n-1)  ##
> s2sq=(n-1)*s^2/qchisq(0.005,n-1)
> s1=sqrt(s1sq)
> s2=sqrt(s2sq)
> s1
[1] 1.026187
> s2
[1] 3.783931
\end{lstlisting}

\vspace{0.2cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %7 mss - page 325 - 例子7.2.2.
设某产品的长度服从正态分布，其均值设定为 240 毫米。现在从一批产品中抽取10件产品，测得长度如下表。
\begin{center}
\begin{tabular}{cccccccccc} \hline 
242 & 243 & 235 & 245 & 234 & 234 & 237 & 238 & 238 & 253 \\ \hline 
\end{tabular}
\end{center}
判断这批产品的长度是否满足设定要求？$\alpha=0.05$. 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{lstlisting}[language=R]
> x=c(242, 243, 235, 245, 234, 234, 237, 238, 238, 253)
> t.test(x,mu=240)  ##

	One Sample t-test

data:  x
t = -0.052959, df = 9, p-value = 0.9589
alternative hypothesis: true mean is not equal to 240
95 percent confidence interval:
 235.6284 244.1716
sample estimates:
mean of x 
    239.9 
\end{lstlisting}

\vspace{2cm}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\item %8 mss - page 384 - 习题7
某粮食加工厂试验三种储藏方法对粮食含水率有无显著影响。
现取—批粮食分成若干份，分别用三种不同的方法（A1, A2, A3）储藏，过一段时间后测得的含水率（单位：\%）如下表。
\begin{center}
\begin{tabular}{c|ccccc} \hline 
A1&7.3&8.3&7.6&8.4&8.3 \\ \hline 
A2&5.4&7.4&7.1&6.8&5.3 \\ \hline 
A3&7.9&9.5&10.0&9.8&8.4 \\ \hline 
\end{tabular}
\end{center}

\begin{enumerate}
\item  用R语言的一个数据框来保存这些数据，一列为含水率，另一列为储藏方法。
\item  假定各种方法储藏的粮食的含水率服从正态分布，且方差相等。使用方差分析，检验这三种方法对含水率有无显著影响。$\alpha= 0.05$. 
\end{enumerate}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{lstlisting}[language=R]
> x1=c(7.3, 8.3, 7.6, 8.4, 8.3)
> x2=c(5.4, 7.4, 7.1, 6.8, 5.3)
> x3=c(7.9, 9.5, 10.0, 9.8, 8.4)
> x=c(x1,x2,x3)  ##
> A=gl(3,5,15)  ##
> mydata=data.frame(x=x,A=A)  ##
> anova(lm(x~A,data=mydata))  ##
Analysis of Variance Table

Response: x
          Df Sum Sq Mean Sq F value   Pr(>F)    
A          2 18.657  9.3287  13.592 0.000825 ***
Residuals 12  8.236  0.6863                     
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
\end{lstlisting}

\vspace{0.2cm}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{enumerate}

\end{document}





